<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.OrderInfo"%>
<%@page import="java.util.List"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="entity.OrderForm"%>
<%@page import="dao.OrderDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <style>
            p{
                font-size: 15px;
            }
        </style>
    </head>
    <body>
        <div style="margin-left: 10px;width: 1200px">
                <h1>订单信息</h1>
                <%
                        int userId=Integer.parseInt(request.getParameter("userid"));
                %>
                <div style="position:absolute;left:200px;top:15px">
                    <h4><a href="MemberInfo.jsp?userid=<%=userId%>">返回</a></h4>
                    </div>
                <%
                    int orderId=Integer.parseInt(request.getParameter("orderid"));
                    OrderForm orderform=new OrderDao().getOrderFormById(orderId);

                    Address address=new AddressDao().getAddressById(orderform.getAddressId());

                %>
                <p>收货地址：<%=address.getAddress()%></p>
                <p>收件人：<%=address.getAddressee()%></p>
                <p>购买时间：<%=orderform.getOrderDate()%></p>
                <p style='font-size: 20px'>购买图书：</p>
                <%
                    List<OrderInfo> list=new OrderDao().getOrderInfo(orderId);
                    float total=0;
                    for(OrderInfo orderinfo:list){
                        Book book=new BookDao().getBookById(orderinfo.getBookId());
                        int count=orderinfo.getCount();
                %>
                <div  style="float:left;margin:10px 10px;width:220px;">
                        <p style="font-size: 15px;width:220px"><%=book.getBookName()%></p>
                        <div>
                            <img style="border-radius: 10px"  src="img/<%=book.getCover()%>" width="220px" height="300px" alt="<%=book.getBookName()%>">
                        </div>
                        <div >
                            <p>编号：<%=book.getId()%></p>
                            <p>作者：<%=book.getAuthor()%></p>
                            <p>数量：<%=count%></p>
                            <p>单价：<%=book.getPrice()%></p>

                            <a href="BookInfo.jsp?bookid=<%=book.getId()%>" target="blank">查看更多</a>
                        </div>               
                    </div>
                        <%
                            total+=count*book.getPrice();
                            }
                        %>
                        <h1 style="clear: both">实付款：<%=total%></h1>
                        <%
                            if(orderform.getIsCheck()==false){
                        %>
                        <h1>未确认收货</h1>
                        <%
                            }else{
                        %>
                        <h1>已确认收货！</h1>
                        <%
                            }
                        %>

                        <%
                            if(orderform.getRate()==0){
                        %>
                        <h3>未评价</h3>
                        <%
                            }else{
                        %>
                        <h3>已评价，评分：<%=orderform.getRate()%></h3>
                        <%
                            }
                        %>
        </div>
    </body>
</html>
